package com.nuoniu.sibanyun.mapper.crm;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nuoniu.sibanyun.entity.crm.CrmSecretKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 秘钥管理 Mapper 接口
 * </p>
 *
 * @author baiqiang
 * @since 2020-07-17
 */
@Component
@Mapper
public interface CrmSecretKeyMapper extends BaseMapper<CrmSecretKey> {

    /**
     * 根据密钥key 检查密钥
     * @author 小啊刚
     * @date 2020-08-03
     */
    @Select("select * from sys_secretkey where secret_key = #{key} and status = 0")
    CrmSecretKey getBySecretKey(String key);

    /**
     * 获取结束的秘钥
     * @author 小啊刚
     * @date 2020-08-03
     */
    @Select("select * from sys_secretkey where end_date < now() and status = 0")
    List<CrmSecretKey> getSecretKeyEnd();
}
